<html>
<!-- Use Meta.transform to set field for horizontal values -->
<style>
 {{{defaultstyle}}}
 body {margin: 20px 20px}
 table {width: 100%; box-shadow: 5 5 10 #777;}
 td, th {border: solid #ddd 1px; font-size: 12px; padding: 2 2;  }
 th {background: #888; color: white; padding: 5px 5px; resize: horizontal;  }
 th a {color: white; text-decoration: none}
 .total {background: #888; color: white}
 tr.odd {background: #eee}
 .cust {font-weight: bold}
</style>

<h2>Sales by State</h2>


<DATAPACKET>
 <METADATA transform="STATE">
  <FIELDS>
   <FIELD name="COMPANY" total="Total" class="cust"/>
   <FIELD name="*" format="# ### ###.##" align="right" total="sum"/>
  </FIELDS>
  <SQL>
   select c.company, c.state, paymentmethod, sum(itemstotal) "VALUE"
   from customer c join orders o on o.custno=c.custno
   group by 1,2,3
   order by 1,2,3
  </SQL>
 </METADATA>
</DATAPACKET>


<br>
<h2>Sales by State/Payment</h2>

<DATAPACKET>
 <METADATA transform="STATE,PAYMENTMETHOD">
  <FIELDS>
   <FIELD name="COMPANY" total="Total" class="cust"/>
   <FIELD name="*" format="# ### ###.##" align="right" total="sum"/>
  </FIELDS>
  <SQL>
   select c.company, c.state, paymentmethod, sum(itemstotal) "VALUE"
   from customer c join orders o on o.custno=c.custno
   where state in ('AL', 'CA', 'FL', 'OR')
   group by 1,2,3
   order by 1,2,3
  </SQL>
 </METADATA>
</DATAPACKET>

</html>
